package com.task.core.domain.info;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.task.common.enums.MissionPageStatusEnum;
import com.task.common.utils.SystemFunctionUtil;
import com.task.common.utils.TableNameUtils;
import com.task.common.utils.date.DateConstants;
import com.task.common.utils.date.DateUtil;
import org.springframework.util.ObjectUtils;

import com.task.core.dto.request.ClientMissionCompleteRequestDTO;

import lombok.Data;

/**
 * @author 迪迦.
 * @date 2025/1/13 16:45
 */
@Data
public class MissionSuccessRedisMap {

  private String tableName;

  private String missionSendCode;

  private Date now;

  private String dateFormat;

  private List<String> dataId;

  private boolean completeStatus;

  private Integer pageStatus;

  private String ipAddress;

  private String ipAddressCountry;

  private String ipAddressState;

  private String ipAddressCity;

  private String description;

  private String clickTime;

  private String userAgent;

  private String imageUrl;

  private String profileUrl;

  private String htmlUrl;

  private String proxy;

  private String devOs;

  private String devOsVersion;

  private String devManufacturer;

  private String devModel;

  private String devBoard;

  private String devBrand;

  private String devHardware;

  private String packageName;

  private List<String> dataSendTableName;

  private Date createDate;

  public MissionSuccessRedisMap(String tableName, String missionSendCode, ClientMissionCompleteRequestDTO request, String dateFormat, Date createDate) {
    this.tableName = tableName;
    this.missionSendCode = missionSendCode;
    this.now = new Date();
    this.dateFormat = dateFormat;
    this.createDate = createDate;

    if (!ObjectUtils.isEmpty(request)) {
      this.completeStatus = request.isSuccess();

      if(MissionPageStatusEnum.GOOD.getInfo().equals(request.getPageStatus())){
        this.pageStatus = Integer.parseInt(MissionPageStatusEnum.GOOD.getCode());
      }else if(MissionPageStatusEnum.BAD.getInfo().equals(request.getPageStatus())){
        this.pageStatus = Integer.parseInt(MissionPageStatusEnum.BAD.getCode());
      }else if(MissionPageStatusEnum.WARN.getInfo().equals(request.getPageStatus())){
        this.pageStatus = Integer.parseInt(MissionPageStatusEnum.WARN.getCode());
      }
      this.dataId = request.getDataId();
      this.ipAddress = request.getIpAddress();
      this.ipAddressCountry = request.getIpAddressCountry();
      this.ipAddressCity = request.getIpAddressCity();
      this.ipAddressState = request.getIpAddressState();
      this.description = request.getDescription();
      this.clickTime = request.getClickTime();
      this.userAgent = request.getUserAgent();
      this.imageUrl = request.getImageUrl();
      this.profileUrl = request.getProfileUrl();
      this.htmlUrl = request.getHtmlUrl();
      this.proxy = request.getProxy();
      this.devOs = request.getDevOs();
      this.devOsVersion = request.getDevOsVersion();
      this.devModel = request.getDevModel();
      this.devBoard = request.getDevBoard();
      this.devBrand = request.getDevBrand();
      this.devHardware = request.getDevHardware();
      this.packageName = request.getPackageName();
      this.dataSendTableName = TableNameUtils.getTableNames(now);
    }
  }

}
